﻿
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>AngularJS  API</title>
    <script type="text/javascript" src="Scripts/angular.js"></script>
</head>
    <body>
        <div ng-app="myApp" ng-controller="myCtrl">
            <input type="text" ng-model="myInput" ng-blur="blur()">
            <p>输入的内容为：{{myInput}}</p>
            <p>变成小写：{{ x1 }}</p>
            <p>变成大写：{{ x2 }}</p>
            <p ng-switch="x3">
                是不是字符串：
                <label ng-switch-when="true">是</label>
                <label ng-switch-when="false">不是</label>
                <label ng-switch-when=""></label>
            </p>
            <p ng-switch="x4">
                是不是数字：
                <label ng-switch-when="true">是</label>
                <label ng-switch-when="false">不是</label>
                <label ng-switch-when=""></label>
            </p>
        </div>
        <script>
            var app = angular.module('myApp', []);
            app.controller('myCtrl', function ($scope) {
                $scope.blur = function () {
                    if ($scope.myInput == '') {
                        $scope.myInput = undefined;
                    }
                    if (!isNaN($scope.myInput)) {
                        $scope.myInput = Number($scope.myInput);
                    }
                    $scope.x1 = angular.lowercase($scope.myInput);
                    $scope.x2 = angular.uppercase($scope.myInput);
                    $scope.x3 = angular.isString($scope.myInput);
                    $scope.x4 = angular.isNumber($scope.myInput);
                }
            });
        </script>
    </body>

</html>